      IMPLICIT REAL*8 (A-H, L-Z)
      real*8 porb,N,N1,dt,a(100,100),m(100),dt1,dt2,dt3(100)
      real*8 m1,m2,tb0,mx,mx2,tbx,eccx,spin2,t1,t2,Tm,f,p(100) 
      open(4,file='hmxbMW.dat',status='unknown')
      open(1001,file='fra.out',status='unknown')            
      m(0) = 0.0
      p(0) = -0.5
      do j = 1, 36
c      m(j) = m(j-1) + 0.5
      p(j) = p(j-1)+0.1
      rewind(4)
      dt2 = 0
      N1 = 0
      TM = 0
      do i = 1,15138
      read(4,112)m1,m2,tb0,mx,mx2,tbx,eccx,t1,t2
c      tbx = Log10(tbx)
      if(mx.ge.0.0.and.mx.le.20.0.and.tbx.le.3.0)then
       dt1 = 1.24*0.3*1.18e-6*m2*m1**-2.7
      write(1000,*)mx,tbx
      else
       dt1 =0
      endif            

       if(tbx.gt.p(j-1).and.tbx.le.p(j).and.tbx.le.1000)then     

      dt2 = dt2+dt1
      dt3(j) = dt2

      endif

      enddo      
      
      write(1001,11) p(j-1),dt3(j)   
      write(1001,11) (p(j-1)+0.1),dt3(j)     
      if(mx.ge.2.0.and.mx.le.20.0.and.tbx.le.1000.0)then
      N = N+dt3(j)
      print*,N
      endif
      enddo
11    format(1f10.2,1E15.3,1i1,1f10.3)
 112  FORMAT(6f10.2,2i3,2f8.3,2f10.3)
      end      
